<!doctype html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="iframe" src="resources/test.html"></iframe>
<script>
async_test(t => {
  const iframe = document.querySelector('#iframe');
  iframe.onload = t.step_func(() => {
    const contentWindow = iframe.contentWindow;
    const xhr = new contentWindow.XMLHttpRequest();
    xhr.open('GET', 'resources/slow-failure.cgi');
    xhr.onloadstart = () => {
      iframe.parentNode.remove(iframe);
    };
    // This should not crash the renderer.
    xhr.send();
    t.done();
  });
}, 'Detach iframe in onloadstart callback.');
</script>
</html>
